#include "actions.hxx"

/*
int action_demo(METHOD_message_t* msg, va_list args) {
	BEGIN;
	END;
}
*/

//TODO: 前后处理(action)

OUR_type_action type_actions[] = {
	//业务对象类型，              动作名称，      前/后处理，              函数名称，    用户参数
	{NULL,                       NULL,          METHOD_pre_action_type, NULL,        NULL}
};

OUR_prop_action prop_actions[] = {
	//业务对象类型， 属性名称，    动作名称,       前/后处理，              函数名称，    用户参数
	{NULL,          NULL,        NULL,          METHOD_post_action_type, NULL,        NULL}
};

int OUR_register_actions(int* decision, va_list args) {
	BEGIN;
	int registered = 0;
	int type_action_size = sizeof(type_actions) / sizeof(OUR_type_action) - 1;
	int prop_action_size = sizeof(prop_actions) / sizeof(OUR_prop_action) - 1;
	for (int i = 0; i < type_action_size; i++) {
		ADD_TYPE_ACTION(type_actions[i].business, type_actions[i].message,
			type_actions[i].type, type_actions[i].func, type_actions[i].args);
		if (ITK_ok == ifail)
			registered++;
	}
	for (int i = 0; i < prop_action_size; i++) {
		ADD_PROP_ACTION(prop_actions[i].business, prop_actions[i].name, prop_actions[i].message,
			prop_actions[i].type, prop_actions[i].func, prop_actions[i].args);
		if (ITK_ok == ifail)
			registered++;
	}
	info_syslog("*There are %d/%d actions in '%s.%s' registered.\n\n",
		registered, type_action_size + prop_action_size, EX_STRING(SITE), __FUNCTION__);
	END;
}
